/*
 * Copyright (C) 2025 ameise <ameise.wang@gmail.com> - All Rights Reserved
 *
 * This file is part of e3time.
 *
 * e3time is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * e3time is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with e3time. If not, see <https://www.gnu.org/licenses/>.
 */

//go:build debug

package e3time

import "time"

func Now() time.Time {
	return time.Now().Add(_gFastDur)
}

func FastForward(dur Duration) error {
	return setFastForwardDuration(_gFastDur + dur)
}

func FastForwardTo(str string, local *Location) error {
	if t, err := time.ParseInLocation(LayoutSec, str, local); err != nil {
		return err
	} else {
		return setFastForwardDuration(t.Sub(Now()))
	}
}

func FastForwardToLocal(str string) error {
	return FastForwardTo(str, time.Local)
}

func FastForwardToUTC(str string) error {
	return FastForwardTo(str, time.UTC)
}

func FastForwardToTimeStamp(timestamp int64) error {
	t := time.Unix(timestamp, 0)
	return setFastForwardDuration(t.Sub(Now()))
}
